-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Create priority_queue_using_list.py #2428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implementation of Priority Queue using lists
Corrected the spelling mistake of fashion
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 820319e0-f6bb-11ea-afed-a1bc0e34d213 |
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: ecb0abe0-f6bb-11ea-afed-a1bc0e34d213 |
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 6c3441b0-f6bc-11ea-afed-a1bc0e34d213 |
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 78e4e4e0-f6bd-11ea-afed-a1bc0e34d213 |
Run |
Seven lines are longer than 88 characters max. |
Removed unwanted white spaces Kept the max char in a line under 88 char Added the suggested if condition for underflow Added the ellipse(...) instead of the entire traceback
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 09b750f0-f729-11ea-bb1a-aff04add7ab5 |
Can be easily fixed. Run |
else: | ||
return self.queue[2].pop(0) | ||
|
||
def print_queue(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def print_queue(self): | |
def __str__(self) -> str: | |
return "Your code goes here..." |
Instead, please do def __str__(self) -> str:
and then we can use str(my_queue)
or print(my_queue)
to see the results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace "Your code goes here..."
with a str that you want to see.
Added the proposed changes
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: 8f540860-f743-11ea-bb1a-aff04add7ab5 |
207 lines now start with indentation that contains tabs |
|
All indentation are spaces
Hey @Ashley-J-George, TravisCI finished with status TravisBuddy Request Identifier: cdbd5de0-f752-11ea-bb1a-aff04add7ab5 |
Travis tests have failedHey @Ashley-J-George, TravisBuddy Request Identifier: 8c02ee50-f753-11ea-bb1a-aff04add7ab5 |
Travis tests have failedHey @Ashley-J-George, TravisBuddy Request Identifier: 64eddce0-f761-11ea-bb1a-aff04add7ab5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be included as an example priority queue data structure.
|
@Ashley-J-George please reopen this PR so that we can finish it. Despite the other comments, three levels is enough for this demonstration algorithm. Just because Priority queues often times use a heap does not mean that they always use a heap, so your list-based approach was fine. Using dequeue or heapq will hide many of the implementation details that make your simple list-based approach so educational. As we say in our README, we are building algorithms to be educational, to highlight concepts, not to be as fast as the Python standard library. |
I have submitted a pull request, you could just go through it.
…On Wed, Sep 16, 2020 at 2:20 AM Christian Clauss ***@***.***> wrote:
@Ashley-J-George <https://github.com/Ashley-J-George> please reopen this
PR so that we can finish it. Despite the other comments, three levels is
enough for this demonstration algorithm. Just because *Priority queues
often times use a heap* does not mean that they always use a heap so your
list-based approach was fine. Using dequeue or heapq will hide many of the
implementation details that make your simple list-based so educational. As
we say in our README, we are building algorithms to be educational, not to
be as fast as the Python standard library.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2428 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJUYHLK2CVNAXRBSCHGXP6TSF7HSDANCNFSM4RL6NONA>
.
|
I am sitting down to go through it but the pull request is closed. |
I had closed the PR and deleted it yesterday so today I sent another new PR
…On Wed, Sep 16, 2020 at 8:34 PM Christian Clauss ***@***.***> wrote:
I am sitting down to go through it but the pull request is closed.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#2428 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJUYHLNJ4NAF3VL7YISI3NLSGDHYHANCNFSM4RL6NONA>
.
|
Merged in #2435 |
Implementation of Priority Queue using lists
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.